$(function(){

	var Request=new UrlSearch(); //实例化
	
	// 城市编号
	var cityNo = Request.cityNo
	
	var json = {};

	$.ajax({
		type: "post",
		url: "/dingding-web/tourismAction!getTourisList.action",
		dataType: "jsonp",
		async: false,
		jsonp: "callback",
		jsonpCallback: "success_jsonp",
		data: {
			"cityNo":cityNo
		},
		success:function(data){

			var tpl = document.getElementById("tpl").innerHTML;
  			var html =juicer(tpl,data);
  			$("body").html(html);

  			// 景点介绍JS

			$('.content-list-li-introduce').on('click',function(){
					var index = $(this).attr('value');					
					$('body').find('.alert-window').eq(index).css('display','block');

			});
			
			$('.content-list-li-introduce').mouseleave(function(){
					var index = $(this).attr('value');				
					$('body').find('.alert-window').eq(index).css('display','none');

			});

			//去这里 javasctipt

			$('.content-list-li-go').on('click',function getPlaceInfo(){
				var index = $(this).attr('value');
				json.latitude = data.responseBody[index].viewSpotLatitude;
				json.longitude = data.responseBody[index].viewSpotLongitude;
				json.name = data.responseBody[index].viewSpotName;
				
				if(isIOS()) {
					//苹果操作
					var message={"name":json.name,"latitude":json.latitude,"longitude":json.longitude};
					window.webkit.messageHandlers.getPlaceInfo.postMessage(message);
				}
				else {
					//android
					JavascriptInterface.getPlaceInfo(json.name,json.longitude,json.latitude);
				}



			});

		}
	});
});

// 获取url中传入的参数
function UrlSearch()
{
   var name,value;
   var str=location.href; //取得整个地址栏
   var num=str.indexOf("?")
   str=str.substr(num+1); //取得所有参数   stringvar.substr(start [, length ]

   var arr=str.split("&"); //各个参数放到数组里
   for(var i=0;i < arr.length;i++){
    num=arr[i].indexOf("=");
    if(num>0){
     name=arr[i].substring(0,num);
     value=arr[i].substr(num+1);
     this[name]=value;
     }
    }
}
